<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button class="out">取消计划调用</button>
  <button class="itv">取消重复调用</button>
  <script>

    function foo(a, b, c) { console.log("----", a, b, c) }

    // 计划调用 3秒后调用
    var tiemoutId = setTimeout(foo, 1000, "a1", "b1", "c1")

    // 重复调用 每3秒调用一次
    var intervalId = setInterval(foo, 1000, "a2", "b2", "c2")

    var outEl = document.querySelector(".out")
    var itvEl = document.querySelector(".itv")
    outEl.onclick = function () {
      console.log("取消计划调用")
      clearTimeout(tiemoutId)
    }
    itvEl.onclick = function () {
      console.log("取消重复调用")
      clearInterval(intervalId)
    }




  </script>
</body>

</html>